{% extends "mainapp/base.html" %}

{% load static %}
{% load bootstrap %}

{% block title %} 用户信息管理 {% endblock %}


{% block content %}
    <h1 class="mt-4">修改用户信息 - {{ user.username }}</h1>
    <div class="row">
        <div class="col-4">
            <form method="post" class="mt-4">
                {% csrf_token %}
                <div class="form-group">
                    {{ form.password.label_tag }}
                    {{ form.password }}
                </div>
                <div class="form-group">
                    {{ form.role.label_tag }}
                    {{ form.role }}
                </div>
                <div class="mt-4">
                    <button type="submit" class="btn btn-primary">保存</button>
                    <a href="{% url 'user_list' %}" class="btn btn-secondary ml-4">返回用户列表</a>
                </div>
            </form>
        </div>
        <div class="col-4">
            {% if form.errors %}
                <div class="alert alert-danger mt-3">
                    <strong>提交错误:</strong>
                    <ul>
                        {% for field, errors in form.errors.items %}
                            {% for error in errors %}
                                <li>{{ field }}: {{ error }}</li>
                            {% endfor %}
                        {% endfor %}
                    </ul>
                </div>
            {% endif %}
        </div>
    </div>


{% endblock %}